use sqlx::SqlitePool;
use crate::db;
use crate::error::AppResult;
use crate::models::User;

pub struct UserService;

impl UserService {
    /// 查找或创建用户
    pub async fn find_or_create_user(pool: &SqlitePool, userid: &str) -> AppResult<User> {
        db::user::find_or_create(pool, userid).await
    }
    
    /// 根据 ID 查找用户
    pub async fn find_by_id(pool: &SqlitePool, id: i64) -> AppResult<Option<User>> {
        db::user::find_by_id(pool, id).await
    }
}
